package org.waddy.framework.app.web.struts;

import java.util.Map;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.commons.lang.builder.EqualsBuilder;
import org.apache.commons.lang.builder.HashCodeBuilder;
import org.apache.commons.lang.builder.ReflectionToStringBuilder;
import org.apache.struts2.interceptor.ServletRequestAware;
import org.apache.struts2.interceptor.ServletResponseAware;
import org.apache.struts2.interceptor.SessionAware;
import org.waddy.framework.app.web.entity.UserContext;

import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.ModelDriven;

/**
 * 系统所有Action的顶级抽象类  （实现session、request、response等Http对象封装）
 * 
 * @author zdp
 * 
 */
public abstract class Action extends ActionSupport implements ModelDriven, SessionAware,
		ServletRequestAware, ServletResponseAware {	

	private static final long serialVersionUID = -2241115958712405398L;

	private Map<String, Object> session;
	private HttpServletRequest request;
	private HttpServletResponse response;
	
	private UserContext userContext;
			
	
	
	public UserContext getUserContext() {
		return userContext;
	}

	public void setUserContext(UserContext userContext) {
		this.userContext = userContext;
	}

	public HttpServletRequest getServletRequest() {
		return request;
	}

	public void setServletRequest(HttpServletRequest request) {
		this.request = request;
	}

	public HttpServletResponse getServletResponse() {
		return response;
	}

	public void setServletResponse(HttpServletResponse response) {
		this.response = response;
	}

	
	public void setSession(Map<String, Object> session) {
		this.session = session;
	}

	public Map<String, Object> getSession() {
		return this.session;
	}

	public String toString() {
		return ReflectionToStringBuilder.reflectionToString(this);
	}

	public boolean equals(Object vo) {
		return EqualsBuilder.reflectionEquals(this, vo);
	}

	public int hashCode() {
		return HashCodeBuilder.reflectionHashCode(this);
	}

}
